const hooks = [];
let currentIndex = 0;
function useState(initData) {
    hooks[currentIndex] = hooks[currentIndex] || initData;
    const _currentIndex = currentIndex;
    const setState = (val) => {
        hooks[_currentIndex] = val;
    };

    return [hooks[currentIndex++], setState];
}

let num = 0;
function render() {
    currentIndex = 0;
    const [count, setCount] = useState(1);
    console.log(count);

    setTimeout(() => {
        setCount(2);
        num++;
        if (num == 2) {
            return
        }
        render();
    }, 100);
};

render();


